package com.example.windweatherapp;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import io.reactivex.rxjava3.annotations.NonNull;

public class GuidePageAdapter extends RecyclerView.Adapter<GuidePageAdapter.GuideViewHolder> {

    private final List<GuidePageItem> items;

    public GuidePageAdapter(List<GuidePageItem> items) {
        this.items = items;
    }

    @NonNull
    @Override
    public GuideViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.guide_page_item, parent, false);
        return new GuideViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull GuideViewHolder holder, int position) {
        GuidePageItem item = items.get(position);
        holder.imageView.setImageResource(item.getImageResId());
        holder.titleTextView.setText(item.getTitle());
        holder.descriptionTextView.setText(item.getDescription());
    }

    @Override
    public int getItemCount() {
        return items.size();
    }

    static class GuideViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView;
        TextView titleTextView;
        TextView descriptionTextView;

        public GuideViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView = itemView.findViewById(R.id.guideImage);
            titleTextView = itemView.findViewById(R.id.guideTitle);
            descriptionTextView = itemView.findViewById(R.id.guideDescription);
        }
    }

    // 引导页数据模型
    public static class GuidePageItem {
        private final int imageResId;
        private final String title;
        private final String description;

        public GuidePageItem(int imageResId, String title, String description) {
            this.imageResId = imageResId;
            this.title = title;
            this.description = description;
        }

        public int getImageResId() {
            return imageResId;
        }

        public String getTitle() {
            return title;
        }

        public String getDescription() {
            return description;
        }
    }
} 